package com.sh.data.engine.domain.api.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sh.data.engine.domain.api.model.domain.DataApiAuthApproveDomain;
import com.sh.data.engine.domain.api.model.domain.DataApiAuthDomain;
import com.sh.data.engine.domain.api.model.domain.DataApiMyApplyDomain;
import com.sh.data.engine.domain.api.model.domain.DataApiTokenDomain;
import com.sh.data.engine.domain.api.model.param.DataApiAuthApproveOrderParam;
import com.sh.data.engine.domain.api.model.param.DataApiAuthApproveParam;
import com.sh.data.engine.repository.dao.api.entity.DataApiAuthEntity;

import java.util.List;

/**
 * @author : fuchen
 * @date : 2022/1/19 15:33
 * <p>API 权限
 */
public interface DataApiAuthService extends IService<DataApiAuthEntity> {

    Long getTotalApplyByProjectId(Long projectId, Integer status);

    Long getTotalApplyByProjectIdAndUserId(Long projectId, Integer status, String userId);

    boolean applyApiById(String userId, Long apiId, Long projectId, String username);

    boolean applyApiByIds(String userId, List<Long> apiId, Long projectId, String username);

    IPage<DataApiAuthApproveDomain> getApiAuthApprovePage(
        DataApiAuthApproveParam dataApiAuthApproveParam);

    Boolean approveUserApiAuthById(DataApiAuthApproveOrderParam dataApiAuthApproveOrderParam);

    Boolean cancelUserApiAuthById(Long id, Integer status);

    DataApiAuthDomain findAuthDomainByUserIdAndApiId(String userId, Long apiId);

    DataApiTokenDomain getApiIdByToken(String token, String apiPath);

    boolean removeDataApiAuthByApiId(Long id);

    List<DataApiAuthEntity> getDataApiAuthByIds(List<Long> ids, String userId, Long projectId);

    boolean deleteApiApproveById(Long id);

    boolean applyApiByAuthId(Long id);

    void initProdApiToRedis();

    boolean exitUsingApiByApiId(Long id);

    void updateApiAuthName(Long apiId, String newName);

    IPage<DataApiMyApplyDomain> getMyApplyApiPage(
        Integer approveStatus,
        String userId,
        Long projectId,
        Integer pageNum,
        Integer pageSize,
        String apiName);
}
